package com.ctshk.rpc.tour.mapper;

import com.ctshk.rpc.tour.base.CustomBaseMapper;
import com.ctshk.rpc.tour.dto.schedule.SeriesTripScheduleDefaultCostDTO;
import com.ctshk.rpc.tour.dto.schedule.SeriesTripScheduleDefaultCostGroupDTO;
import com.ctshk.rpc.tour.entity.SeriesTripScheduleDefaultCost;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 团期成本分摊默认 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-21
 */
public interface SeriesTripScheduleDefaultCostMapper extends CustomBaseMapper<SeriesTripScheduleDefaultCost> {

    @Select({
            "<script>",
            "SELECT trip_id,group_customer_price ",
            "FROM t_series_trip_schedule_default_cost ",
            "WHERE is_deleted =0 and trip_id IN ",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    List<SeriesTripScheduleDefaultCost> getDefaultCost(@Param("ids") List<Long> ids);

    @Select("SELECT group_customer_price FROM t_series_trip_schedule_default_cost WHERE trip_id = #{id} ORDER BY group_customer_price")
    String getDefaultCostByTripId(@Param("id") Long id);

    @Update("update t_series_trip_schedule_default_cost set is_deleted = 1 where schedule_id=#{scheduleId}")
    int deleteByScheduleId(@Param("scheduleId")Long scheduleId);
}
